layui.use(['element', 'form', 'layer'], function () {

    var form = layui.form;
    var layer = layui.layer;
    var element = layui.element;

    $('.input-field').on('change', function () {
        var $this = $(this),
            value = $.trim($this.val()),
            $parent = $this.parent();

        if (value !== '' && !$parent.hasClass('field-focus')) {
            $parent.addClass('field-focus');
        } else {
            $parent.removeClass('field-focus');
        }
    })
    form.on('submit(login)', function (data) {
        var Admin = {"aId": null, "aName": $("#u_name").val(), "aPwd": $("#u_pwd").val()};
        $.ajax({
            url: "/games_info_sys/admin/adminLogin.do",
            type: "POST",
            contentType: "application/json",
            data: JSON.stringify(Admin),
            success: function (res) {//发送成功
                if (res.msg == "登陆成功") {//判断账户是否登录成功
                    $.cookie('loginAdminId', null);//清除原有cookie
                    window.location.replace("/games_info_sys/backstage_web/index.html");
                    $.cookie('loginAdminId', res.data.aName);//写入加密用户名cookie
                } else {
                    layer.msg(res.msg);
                }
            }
        });

        return false;
    });
});
